package com.example.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.demo.domain.Comment;
import com.example.demo.service.CommentService;

@Controller
@RequestMapping("/comment")
public class CommentController {
	private final Logger logger = LoggerFactory.getLogger(this.getClass());
	@Autowired
	CommentService commentService;
	
	@RequestMapping("/add")
	@ResponseBody
	public String addComment() {
		logger.info("CommentController: addComment()");
		//接收session中的uid，
		//接收Comment
		//调用Service添加
		//返回链接，/article/{aid} //文章ID从Comment中获取
		
		Comment c = new Comment();
		c.setUid(1000000073);
		c.setAid(Long.valueOf("16"));
		c.setContent("哈哈");
		return String.valueOf(commentService.addComment(c));
	}
}
